#ifndef MYMODBUS_H
#define MYMODBUS_H

#include <QModbusDataUnit>
#include <QObject>

class QModbusClient;
class QModbusReply;
class WriteRegisterModel;

class MyModbus : public QObject {
    Q_OBJECT
public:
    explicit MyModbus( QObject* parent = nullptr );
    ~MyModbus();
    void onReadModbus( const QModbusDataUnit readRequest );
    void onWriterModbus( const QModbusDataUnit writerRequest );
    void onDisconnct();
    void connectModbus();
    void initModbus();

public slots:
    void onModbusStateChanged( int state );
    void onReady();
signals:
    void sigModbusStateChanged( const int state );
    void sigModbusConnectError( const QString& errorInfo );
    void sigModbusReadError( const QString& errorInfo );
    void sigModbusWriterError( const QString& errorInfo );
    void sigModbusConnectSuccesful();
    void sigModbusReady( const QModbusDataUnit unit );

private:
    QModbusClient* modbusDevice = nullptr;
};

#endif  // MYMODBUS_H
